/*******************************************************************************
* Purpose: Construct measures of parenting
* 
* Dependencies:
*   Input: HOME_12m.dta
*		   HOME_36m.dta
*   Output: parenting_inputs.dta
*
* Notes: -
*******************************************************************************/
set more off
clear all

global storage: env storage

use "$storage/ece_parenting/raw_data/DSC0001.dta"
keep IHDP PAG
merge 1:1 IHDP using "$storage/ece_parenting/intermediate_data/HOME/HOME_12m.dta", generate(_mergeHOME12)
merge 1:1 IHDP using "$storage/ece_parenting/intermediate_data/HOME/HOME_36m.dta", generate(_mergeHOME36)
drop _mergeHOME12 _mergeHOME36

////////////////////////////////////////////////////////////////////////////////
////////////////////////// Parenting Inputs ////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// generate average of parenting
egen avg_parenting = rowmean(parenting_12_alt parenting_36_alt)
lab var avg_parenting "Average of Parenting Latents"
drop parenting_12_alt parenting_36_alt
// generate final parenting measure
egen std_avg_parenting = std(avg_parenting)
lab var std_avg_parenting "Final Parenting Measure"
// generate alternative parenting measure
egen par_alt = rowtotal(alt_parenting_12_raw alt_parenting_36_raw)
lab var par_alt "Total Parenting Score on Alternative Subscales"
drop alt_parenting_12_raw alt_parenting_36_raw

// save 
capture mkdir "$storage/ece_parenting/intermediate_data/inputs"
save "$storage/ece_parenting/intermediate_data/inputs/parenting_inputs.dta", replace
